Repository navigation
Destroy heap array elements in reverse order - #684
Merged
nunoplopes merged 3 commits intoNov 26, 2026
Merged
Conversation
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Heap
delete[]calls nontrivial element destructors in forward order in both output models, so later elements can be torn down after objects they depend on. The generated loops now run from the last index to the first, before releasing the allocation.cc @lucic71 @nunoplopes
The fixture in
tests/unit/delete_array_order.cppallocates three records with id/value pairs1:10,2:20, and3:30. Native C++ prints3:30 2:20 1:10; the prior translations printed the opposite order. Both translations now match native output, retaining each element's stored value.The change reverses the existing ranges rather than introducing another destruction mechanism. Argument evaluation, element-count calculation, and deallocation calls are unchanged. Scalar deletion and trivial element handling are unchanged too. Both generated Rust expectations accompany the new fixture.
The unsafe model still infers array lengths from allocator size; padding and zero-length allocation handling are unchanged.
The scoped Debug and Release lit runs each passed 8 tests, with 0 failures and 0 skips, covering heap allocation/deletion, destructor handling, and the new order fixture in both models. Clang-format and generated-Rust formatting checks passed.
Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart.